<?php    
header('Content-type: application/xls');
header("Content-Disposition:attachment;filename=theodoidb.xls");

?>
<?php
    echo $others->conghoa($tendv ['Zdv'] ['tendvcha'] ,$tendv ['Zdv'] ['tendv'],3,4,
        'Theo dõi các công tác tại điểm bán'); 
?>
<?php $songay = date('d-m-Y',strtotime($cuoithang)) - date('d-m-Y',strtotime($dauthang))+1;?>
<table border="1">
<tr>
<th style="background: #d5d5d5; font-weight:bold" rowspan=2>STT</th>
<th style="background: #d5d5d5; font-weight:bold" rowspan=2>Đơn vị</th>
<th style="background: #d5d5d5; font-weight:bold" rowspan=2>Nhân viên đa nhiệm</th>
<th style="background: #d5d5d5; font-weight:bold" rowspan=2>Mã kênh</th>
<th style="background: #d5d5d5; font-weight:bold" rowspan=2>Kênh</th>
<th style="background: #d5d5d5; font-weight:bold" colspan=3>Hình ảnh điểm bán</th>
<th style="background: #d5d5d5; font-weight:bold" rowspan=2>Thông tin thị trường</th>
<th style="background: #d5d5d5; font-weight:bold" colspan=<?php echo $songay?>>Tần suất chăm sóc</th>
</tr>
<tr>
<th>Hình Ảnh</th>
<th >Poster</th>
<th >Kệ tời rơi</th>
<?php
$date = date('d-m-Y',strtotime($dauthang));
for($i=0;$i<$songay;$i++)
{
?>
<th><?php echo $date?></th>
<?php $date=date('d-m-Y',StrToTime('+1 days', strtotime($date))); }?>
</tr>

<?php
$i = 0;
 foreach ($kenhinfo as $info)
{?>
<tr>
<td><?php echo ++$i?></td>
<td><?php echo $info['Nhanvien']['Donvi']['madv']?></td>
<td><?php echo $info['Nhanvien']['tennv']?></td>
<td><?php echo $info['Kenh']['makenh']?></td>
<td><?php echo $info['Kenh']['tenkenh']?></td>
<td>
<?php foreach($congtackenhs as $congtackenh)
		if($congtackenh['Congtackenh']['kenh_id']==$info['Kenh']['id'])
		{
			echo $congtackenh['Congtackenh']['hinhanh'];
			break;
		}
			
?>
</td>
<td>
<?php foreach($congtackenhs as $congtackenh)
		if($congtackenh['Congtackenh']['kenh_id']==$info['Kenh']['id'])
		{
			echo $congtackenh['Congtackenh']['poster'];
			break;
		}
			
?>
</td>
<td>
<?php foreach($congtackenhs as $congtackenh)
		if($congtackenh['Congtackenh']['kenh_id']==$info['Kenh']['id'])
		{
			echo $congtackenh['Congtackenh']['toroi'];
			break;
		}
			
?>
</td>
<td>
<?php foreach($thongtintts as $thongtintt)
		if($thongtintt['Thitruongkenh']['Kenh_id']==$info['Kenh']['id'])
		{
			echo '- ' .$thongtintt[0]['thitruong'];
			break;
		}
			
?>
</td>
<?php
$date = date('d-m-Y',strtotime($dauthang));
for($i=0;$i<$songay;$i++)
{
?>
<td><?php
$check=0;
		foreach ($chamsocs as $chamsock =>$chamsocv)
		{
			if($chamsock==$info['Kenh']['id'] && date('d-m-Y',strtotime($chamsocv))==$date)
			{
				echo $html->image($this->webroot.'img/check.gif',null);
				$check=1;
				break;
			}
		}
		if($check==0){}
			 //echo $html->image($this->webroot.'img/uncheck.gif',null);
		
		?></td>
<?php $date=date('d-m-Y',StrToTime('+1 days', strtotime($date))); }?> 
</tr>
<?php }?>
</table>